<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>添加消息</title>
</head>
<link rel="stylesheet" href="../assets/layui/css/layui.css" media="all"/>
<body style="margin: 10px">
<h3 align="center"><font color="red">谨慎填写无法修改</font></h3>
<hr>
<fieldset class="layui-elem-field">
    <legend>消息标题</legend>
    <input type="text" name="title" id="title" class="layui-input" placeholder="标题">
</fieldset>
<fieldset class="layui-elem-field">
    <legend>消息内容</legend>
    <textarea name="" required lay-verify="required" placeholder="请输入" class="layui-textarea" id="content"></textarea
</fieldset>
<hr>
<div class="layui-input-inline">
    <div class="layui-form-item">
        <button type="button" class="layui-btn" id="push">提交</button>
    </div>
</div>
</body>

<script type="text/javascript" src="../assets/layui/layui.js"></script>
<script type="text/javascript" src="../assets/jquery.min.js"></script>
<script>
    layui.use(['form', 'layedit', 'laydate'], function () {
        var form = layui.form
            , layer = layui.layer
            , layedit = layui.layedit
            , laydate = layui.laydate;

    });

    $("#push").click(function () {

        var title = $("#title").val()
        var content = $("#content").val()
        $.ajax({
            type: "post",
            contentType: "application/x-www-form-urlencoded",
            url: "/api/v1/msg/add",
            data: {
                "title":title,
                "content":content
            },
            dataType: "json",
            success: function (data) {
                if (data.resultTypeEnum == 200) {
                    layer.msg("操作成功", {
                        icon: 1
                    });
                    var index = parent.layer.getFrameIndex(window.name);

                    parent.layui.table.reload('test');
                    //关闭父级页面的表格
                }else {
                    layer.msg(data.message, {
                        icon: 5
                    });
                }
            }
        });
    })
</script>
</html>